freeslot("sfx_s2gbrk","sfx_s2gfal","sfx_s2ggps","sfx_s2ggpl","sfx_s2ghit","sfx_s2gjmp","sfx_s2grng","sfx_s2gpan","sfx_s2gdie","sfx_s2grol","sfx_s2gskd","sfx_s2gspg")

local sounds = {{og = sfx_jump, new = sfx_s2gjmp},
				{og = sfx_skid, new = sfx_s2gskd},
				{og = sfx_itemup, new = sfx_s2grng},
				{og = sfx_spin, new = sfx_s2grol},
				{og = sfx_altow1, new = sfx_s2gpan},
				{og = sfx_altow2, new = sfx_s2gpan},
				{og = sfx_altow3, new = sfx_s2gpan},
				{og = sfx_altow4, new = sfx_s2gpan},
				}

addHook("PlayerThink", function(p)
	if not mapheaderinfo[gamemap].s2gg then return end
	if p.mo and p.mo.valid then
		
		--sound replacement
		for k, t in pairs(sounds)
			if S_SoundPlaying(p.mo,t.og) then
				S_StopSoundByID(p.mo,t.og)
				S_StopSoundByID(p.mo,t.new)
				S_StartSound(p.mo,t.new)
			end
		end
		
		--death msuic and shit
		if p.playerstate == PST_DEAD then
			if not p.dieded then
				S_StopMusic(p)
				S_StopSound(p.mo)
				S_StartSound(p.mo,sfx_s2gdie)
				p.dieded = true
			end
		else
			if p.dieded then
				p.dieded = nil
				P_RestoreMusic(p)
			end
		end
		
		--falling sound
		if not P_IsObjectOnGround(p.mo) and not (p.pflags & PF_JUMPED) and p.mo.momz < -10*FRACUNIT
		and p.playerstate != PST_DEAD and not P_PlayerInPain(p) and not p.powers[pw_carry] then
			if not p.mo.s2g_fall then
				S_StartSound(p.mo,sfx_s2gfal)
				p.mo.s2g_fall = 1
			end
		end
		
		if p.mo.momz > -10*FRACUNIT then
			if p.mo.s2g_fall then
				p.mo.s2g_fall = nil
				S_StopSoundByID(p.mo,sfx_s2gfal)
			end
		end
		
	end
end)

addHook("MobjThinker", function(m)
	if not mapheaderinfo[gamemap].s2gg then return end
	if S_SoundPlaying(m,sfx_spring) then
		S_StopSoundByID(m,sfx_spring)
		S_StartSound(m,sfx_s2gspg)
	end
end, MT_REDSPRING)

addHook("MobjThinker", function(m)
	if not mapheaderinfo[gamemap].s2gg then return end
	if S_SoundPlaying(m,sfx_spring) then
		S_StopSoundByID(m,sfx_spring)
		S_StartSound(m,sfx_s2gspg)
	end
end, MT_YELLOWHORIZ)

addHook("MobjThinker", function(m)
	if not mapheaderinfo[gamemap].s2gg then return end
	if S_SoundPlaying(m,sfx_pop) then
		S_StopSoundByID(m,sfx_pop)
		S_StartSound(m,sfx_s2ghit)
	end
end, MT_BLUECRAWLA)

addHook("MobjThinker", function(m)
	if not mapheaderinfo[gamemap].s2gg then return end
	if S_SoundPlaying(m,sfx_pop) then
		S_StopSoundByID(m,sfx_pop)
		S_StartSound(m,sfx_s2ghit)
	end
end, MT_RING_BOX)

addHook("MobjThinker", function(m)
	if not mapheaderinfo[gamemap].s2gg then return end
	if S_SoundPlaying(m,sfx_pop) then
		S_StopSoundByID(m,sfx_pop)
		S_StartSound(m,sfx_s2ghit)
	end
end, MT_1UP_BOX)

addHook("MobjThinker", function(m)
	if not mapheaderinfo[gamemap].s2gg then return end
	if S_SoundPlaying(m,sfx_pop) then
		S_StopSoundByID(m,sfx_pop)
		S_StartSound(m,sfx_s2ghit)
	end
end, MT_INVULN_BOX)

addHook("MobjThinker", function(m)
	if not mapheaderinfo[gamemap].s2gg then return end
	if S_SoundPlaying(m,sfx_pop) then
		S_StopSoundByID(m,sfx_pop)
		S_StartSound(m,sfx_s2ghit)
	end
end, MT_SNEAKERS_BOX)